<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>新媒体渠道</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./lib/layui/css/layui.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="./css/style.css">
    <style>
        input[type='text'][disabled] {
            background-color: white;
            border: none;
            color: black;
        }
        
        .warp {
            /* width: 1200px; */
            overflow-x: scroll;
        }
        
        #table1 {
            /* width: 1280px; */
        }
    </style>
</head>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">渠道管理</a>
        <a>
          <cite>新媒体渠道</cite></a>
      </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>

    <div class="x-body">

        <xblock>
            <button class="layui-btn  layui-btn-normal" onclick="addLie()"><i class="layui-icon"></i>添加品牌</button>
            <button class="layui-btn layui-btn-warm" onclick="addHang()"><i class="layui-icon"></i>添加平台</button>
            <span class="x-right   Reading " onclick="addAll()" style="line-height:40px"> <img src="images/时间.png" alt="">录入本周阅读量</span>
            <div class="x-right none ReadingChoice">
                <button class="layui-btn layui-btn-small layui-btn-radius layui-btn-primary ok">保存</button>
                <button class="layui-btn layui-btn-small layui-btn-radius layui-btn-primary no-ok">取消</button>
            </div>
        </xblock>

        <div class="warp">
            <table class="layui-table" id="table1">
                <thead>
                    <tr class="brand">
                        <th></th>
                        <th>
                            <input type="text" placeholder="请输入平台名称" name="count" value="新加坡教育网" class="left sr none">
                            <div class="miedia-cho  none">
                                <img src="images/yes2.png" alt="">
                                <img src="images/jian.png" alt="" onclick="member_delhang(this,'要删除的id')" href="javascript:;">
                            </div>
                            <span class="bb">新加坡教育网 </span>

                        </th>
                        <th>
                            <input type="text" placeholder="请输入平台名称" name="count" value="考拉留学" class="left sr none">
                            <div class="miedia-cho  none">
                                <img src="images/yes2.png" alt="">
                                <img src="images/jian.png" alt="" onclick="member_delhang(this,'要删除的id')" href="javascript:;">
                            </div>
                            <span class="bb">考拉留学 </span>
                        </th>
                        <th><input type="text" placeholder="请输入平台名称" name="count" value="课窝教育" class="left sr none">
                            <div class="miedia-cho  none">
                                <img src="images/yes2.png" alt="">
                                <img src="images/jian.png" alt="" onclick="member_delhang(this,'要删除的id')" href="javascript:;">
                            </div>
                            <span class="bb">课窝教育</span></th>
                        <th><input type="text" placeholder="请输入平台名称" name="count" value="留学说" class="left sr none">
                            <div class="miedia-cho none">
                                <img src="images/yes2.png" alt="">
                                <img src="images/jian.png" alt="" onclick="member_delhang(this,'要删除的id')" href="javascript:;">
                            </div>
                            <span class="bb">留学说 </span></th>
                        <th><input type="text" placeholder="请输入平台名称" name="count" value="北美家长帮" class="left sr none">
                            <div class="miedia-cho none">
                                <img src="images/yes2.png" alt="">
                                <img src="images/jian.png" alt="" onclick="member_delhang(this,'要删除的id')" href="javascript:;">
                            </div>
                            <span class="bb">北美家长帮 </span></th>

                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><input type="text" placeholder="请输入平台名称" name="count" value="微信公众号" class="left sr none">
                            <div class="miedia-cho  none">
                                <img src="images/yes2.png" alt="">
                                <img src="images/jian.png" alt="" onclick="member_del(this,'要删除的id')" href="javascript:;">
                            </div>
                            <span class="bb">微信公众号 </span>
                        </td>
                        <td>
                            <ul class="newnum">
                                <li>新加坡留学网</li>
                                <li><img src="images/眼睛.png" alt="" class="eyes"> <span class="readNum">112321</span></li>
                            </ul>
                            <input type="text" placeholder="请输入本周阅读量" name="count" value='' class="newinput none">
                        </td>
                        <td>
                            <ul class="newnum">
                                <li>新加坡留学网</li>
                                <li><img src="images/眼睛.png" alt="" class="eyes"> <span class="readNum">112321</span></li>
                            </ul>
                            <input type="text" placeholder="请输入本周阅读量" name="count" value='' class="newinput none">
                        </td>
                        <td>
                            <ul class="newnum">
                                <li>新加坡留学网</li>
                                <li><img src="images/眼睛.png" alt="" class="eyes"> <span class="readNum">112321</span></li>
                            </ul>
                            <input type="text" placeholder="请输入本周阅读量" name="count" value='' class="newinput none">
                        </td>
                        <td>
                            <ul class="newnum">
                                <li>新加坡留学网</li>
                                <li><img src="images/眼睛.png" alt="" class="eyes"> <span class="readNum">112321</span></li>
                            </ul>
                            <input type="text" placeholder="请输入本周阅读量" name="count" value='' class="newinput none">
                        </td>
                        <td>
                            <ul class="newnum">
                                <li>新加坡留学网</li>
                                <li><img src="images/眼睛.png" alt="" class="eyes"> <span class="readNum">112321</span></li>
                            </ul>
                            <input type="text" placeholder="请输入本周阅读量" name="count" value='' class="newinput none">
                        </td>
                    </tr>





                </tbody>
            </table>
        </div>


    </div>

    <script type="text/javascript" src="./js/jquery-3.2.1.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript">
        $(function() {
            var ls = $("#table1 th").length;
            var tabls = ls * 225;
            var winls = $(window).width() //显示器宽度
            var warpbox = winls - 50;
            if (tabls > winls) {
                $(".warp").width(warpbox)
                $("#table1").width(tabls)
            }

        })
        layui.use(['layer', 'form'], function() { //点击单元格出现查看弹窗
            var layer = layui.layer,
                form = layui.form;
//            列标签点击弹出情况
            $(".newnum").click(function() {
                //              x_admin_show('账号详情','./media-show.html',300,360);
                layer.open({
                    type: 2
                        ,
                    title: '账号详情',
                    area: ['300px', '320px'],
                    shade: 0,
                    maxmin: true

                    ,
                    content: 'media-show.html',
                    btnAlign: 'c' //按钮居中
                        ,
                    btn: ['修改', '删除']
                        ,
                    yes: function() {
                        layer.open({
                            type: 2,
                            title: '修改信息',
                            area: ['600px', '360px'],
                            maxmin: true,
                            content: 'media-add.html',
                            zIndex: layer.zIndex,
                            success: function(layero) {
                                layer.setTop(layero);
                            }
                        })

                    },
                    btn2: function() {
                        layer.confirm('确认要删除吗？', {
                            title: '确认删除'
                        }, function(index) {
                            //发异步删除数据
                            //            layer.closeAll();
                            parent.layer.closeAll();
                            layer.msg('已删除!', {
                                icon: 1,
                                time: 1000
                            });

                        });
                    }

                    ,
                    zIndex: layer.zIndex //重点1
                        ,
                    success: function(layero) {
                        layer.setTop(layero); //重点2
                    }
                });
            })
        });


        function member_delhang(obj, id) {

            layer.confirm('确认要删除吗？', {
                title: '确认删除'
            }, function(index) {
                //发异步删除数据
//                $(obj).parents("tr").remove();
                layer.msg('已删除!', {
                    icon: 1,
                    time: 1000
                });
            });
        }

        function addHang() { //添加平台
            var a = $("#table1>thead>tr>th").length;
            var table1 = $('#table1');
            var firstTr = table1.find('tbody>tr:first');
            var row = $("<tr></tr>");
            for (var i = 0; i < a; i++) {
                var td = $("<td></td>");
                if (i < 1) {
                    td.append($("<input type='text'  placeholder='请输入平台名称' name='count' value=''> <span class='kk bb'><i class='layui-icon'>&#xe618;</i>                        </span>"));
                } else {
                    td.append($("<span class='addic' onclick=\"x_admin_show('新增账号','./media-add.html',600,360)\"><button class='layui-btn layui-btn-small layui-btn-radius layui-btn-primary'><i class='layui-icon'>&#xe608;</i>  添加</button></span>"));
                    // td.html("CheckBox");
                }
                row.append(td);
                table1.append(row);
            }
            kk();
        }

        function addLie() {
            //添加品牌
            $th = $("<th><input type='text'  placeholder='请输入品牌名称' name='count' value=''> <span class='kk'><i class='layui-icon'>&#xe618;</i>        </span></th>");
            $col = $("<td class='addic' onclick=\"x_admin_show('新增账号','./media-add.html',600,360)\"><button class='layui-btn layui-btn-small layui-btn-radius layui-btn-primary'><i class='layui-icon'>&#xe608;</i>  添加</button></td>");
            $("#table1>thead>tr").append($th);
            $("#table1>tbody>tr").append($col);
            kk();
        }

        function addAll() {
            //录入数据
            $(".Reading").hide();
            $(".ReadingChoice").show();
            $(".newinput").change(function() { //输入框变化赋值
                var a = $(this).val();

                var $this = $(this);
                $(".ok").click(function() {
                    $this.siblings().find('span').html(a);
                    //保存
                    $(".newnum").show(); //保存按钮和阅读量切换
                    $(".newinput").hide();
                    $(".Reading").show();
                    $(".ReadingChoice").hide();
                })
            });
            $(".newnum").hide();
            $(".newinput").show();
            $(".no-ok").click(function() {
                //取消
                $(".newnum").show(); //保存按钮和阅读量切换
                $(".newinput").hide();
                $(".Reading").show();
                $(".ReadingChoice").hide();
            })
        }

        function kk() {
            $(".kk").on('click', function(event) {
                var pp = $(this).siblings().val(); //增加的品牌的名称
                if (pp) {
                    $(this).text(pp);
                    $(this).siblings().hide();
                }
            });
        }

        function delLie() {
            //移除最后一列
            $("#table1 tr :nth-child(3)").remove();
            //        console.log($("#table1 tr :last-child"))
            console.log(222)
        }

        $(".bb").click(function() { //平台触摸编辑
            $(this).hide();
            $(this).siblings().show();
//            $(this).parent().append()

        })
        $(".miedia-cho>img:nth-child(1)").click(function() { //平台中讲input的值放给span显示出来
            var x = $(this).parent().siblings("input").val();
            $(this).parent().parent().children().hide();
            $(this).parent().siblings(".bb").html(x).show();

        })
    </script>
    <script>
        function member_del(obj, id) {
            var data = $(obj).parent().parent().children().html();
            console.log(data)
            layer.confirm('确认要删除' + data + '吗？', {
                title: '确认删除'
            }, function(index) {
                //发异步删除数据
                $(obj).parents("tr").remove();
                layer.msg('已删除!', {
                    icon: 1,
                    time: 1000
                });
            });
        }
    </script>
    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</body>

</html>